﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using SES.CMS.DO;
using SES.CMS.BL;

namespace SES.CMS.Module
{
    public partial class ucLeftMenu : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                rptCategoryDataSource();
        }
        public void rptCategoryDataSource()
        {
            string url = Request.Url.AbsolutePath;
            url = url.Substring(1, url.Length - 1);
            string url1 = url.Replace(".", "/");
            string Module = url1.Substring(0, url1.IndexOf("/"));
            if (Module.ToLower().Equals("default") || Module.Equals(""))
            {
                rptCategory.DataSource = new DataView(new cmsLoaiSanPhamBL().SelectAll(0), "ParentID>0 AND IsLeftMenu = True", "", DataViewRowState.CurrentRows);
            }
            else
            {
                rptCategory.DataSource = new DataView(new cmsLoaiSanPhamBL().SelectAll(0), "ParentID>0", "", DataViewRowState.CurrentRows);
            }
            rptCategory.DataBind();
        }

        //protected void rptCategory_ItemDataBound(object sender, RepeaterItemEventArgs e)
        //{
        //    RepeaterItem item = e.Item;
        //    if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        //    {
        //        DataRowView drv = (DataRowView)item.DataItem;

        //        int loaiSanPhamID = int.Parse(drv["LoaiSanPhamID"].ToString());
        //        Repeater rptChildMenu = (Repeater)e.Item.FindControl("rptChildMenu");
        //        rptChildMenu.DataSource = new cmsLoaiSanPhamBL().BindLeftMenu(loaiSanPhamID);
        //        rptChildMenu.DataBind();
        //    }
        //}
        //protected void rptChildMenu_ItemDataBound(object sender, RepeaterItemEventArgs e)
        //{
        //    RepeaterItem item = e.Item;
        //    if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        //    {
        //        DataRowView drv = (DataRowView)item.DataItem;

        //        int loaiSanPhamID = int.Parse(drv["LoaiSanPhamID"].ToString());
        //        Repeater rptHoverMenu = (Repeater)e.Item.FindControl("rptHoverMenu");
        //        rptHoverMenu.DataSource = new DataView(new cmsLoaiSanPhamBL().SelectAll(0), "ParentID=" + loaiSanPhamID, "", DataViewRowState.CurrentRows);
        //        rptHoverMenu.DataBind();
        //    }
        //}
        protected string FriendlyUrl(string strTitle)
        {
            return Ultility.Change_AV(strTitle);
        }
    }
}